package sfs2x.extensions.game.src;


import com.smartfoxserver.v2.db.IDBManager;
import com.smartfoxserver.v2.entities.User;
import com.smartfoxserver.v2.entities.data.ISFSArray;
import com.smartfoxserver.v2.entities.data.ISFSObject;
import com.smartfoxserver.v2.entities.data.SFSObject;
import com.smartfoxserver.v2.extensions.BaseClientRequestHandler;

public class Teknolojiler extends BaseClientRequestHandler {
      
	  public void handleClientRequest(User arg0, ISFSObject params)
	  {
		  IDBManager dbManager = getParentExtension().getParentZone().getDBManager();
	        ISFSObject rtn = new SFSObject();
	        String statement = null;
	        ISFSObject abk = new SFSObject();
	       
	        try{
	        	trace("Teknolojiler:");
	         statement = "SELECT teknoloji_id FROM kullanici k,KullaniciTeknolojileri kt where k.Login_isim = '"+arg0.getName()+"' and kt.kullanici_id = k.idKullanici";
	      
	         ISFSArray tek = dbManager.executeQuery(statement);
	         int size = tek.size();
	         
   		     for(int i= 0; i<size; i++){
   			  abk = tek.getSFSObject(i);
   			  int teknolojiid= abk.getInt("teknoloji_id");
   			  trace(teknolojiid);
   			  //trace(i);
   			  //trace(abk.getInt("seviye"));
   			  //rtn.putInt("id"+i,  teknolojiid);
   			  //rtn.putInt("seviye"+i, abk.getInt("seviye"));
   			   }
   		     
   		     
	        }
   		     catch (Exception e) {
    		  e.printStackTrace();
			  trace("SQL Error: Statement = "+ statement);
		     }
   		     
   		    
   		    GameExtension parentEx = (GameExtension) getParentExtension();
		    parentEx.send("KullaniciTeknolojileriCevap", rtn, arg0);
   		
	        
	       
	  }
}
